<?php

class Communication_Bootstrap extends Zend_Application_Module_Bootstrap
{
	public function _initZendMail() {
		$path=APPLICATION_PATH."/modules/communication/settings/email.ini";
		$config=new Zend_Config_Ini($path);
		$sender=false;
		switch ($config->transport){
			case "smtp":{
				$sender=$config->smtpusername;
				$server=$config->smtpserver;
				$transportconfig = array('auth' => $config->smtpauth,
                'username' => $config->smtpusername,
                'password' =>  $config->smtppassword);
				if ($config->port) $transportconfig['port']=$config->port;
				if ($config->encrypt) {
					$encrypt = strtolower($config->encrypt);
					$transportconfig[$encrypt]=$encrypt;
				}
				
				$transport=new Zend_Mail_Transport_Smtp($server,$transportconfig);
				break;		
			}
			default:{
				$transport=new Zend_Mail_Transport_Sendmail();
				break;
			}
		}
		Zend_Mail::setDefaultTransport($transport);
		if ( $sender ) Zend_Mail::setDefaultFrom($sender);
	}
}
